package com.example.springboot.common.system;

import com.example.springboot.entity.LoginUser;

/**
 * @author 菜篮
 * @version 1.0
 * @describe
 * @date 2023/9/30 8:56
 */

//线程隔离性
//简化传递参数
//方便的访问
public class UserHolder {
    public static final ThreadLocal<LoginUser> managerThreadLocal = new ThreadLocal<>();

    public static void saveLoginUser(LoginUser user) {
        managerThreadLocal.set(user);
    }

    public static LoginUser getLoginUser() {
        return managerThreadLocal.get();
    }

    public static void removeLoginManager() {
        managerThreadLocal.remove();
    }
}
